//
//  TrackManager.h
//  NXTRemoteController
//
//  Created by naceka on 05.06.12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Robot.h"
#import "Motion.h"
#import "GestureView.h"

//notification about new data
@protocol TrackManagerDelegate
@optional
- (void) robotStopped;
@end

//dont replace directions!
enum MoveDirection {
	MoveDirection_UNDEF,
	MoveDirection_UP,
	MoveDirection_RIGHT,
	MoveDirection_DOWN,
	MoveDirection_LEFT
};

@interface TrackManager : NSObject {
	Robot * robot;
	GestureView * view;
	Motion * motions[1000];
	int motions_count;
	NSTimer * timer;
	int current_step;
	char speed;
	id <TrackManagerDelegate> delegate;
	
	//times
	float timeForward, timeLeft, timeRight, timeTurn;
}

- (TrackManager *) initWithRobot:(Robot *) r andView:(GestureView *) v;

//path computing
- (void) computePath;
- (enum MoveDirection) getDirectionOfSegmentFrom:(CGPoint *) a To:(CGPoint *) b;
- (void) addMotionWithLen:(int) l andDirection:(enum MotionDirection) d; 

//time
- (void) setTimeToForward:(float) f Left:(float) l Right:(float) r Turn:(float) t;

//Robot move
- (void) startRobotMotion;
- (void) nextStep;
- (void) stopRobotMotion;

//delegate
- (void) setDelegate:(id <TrackManagerDelegate>) d;
@end
